package com.jiangyg.mall.authz.feign.fallback;

import com.jiangyg.mall.authz.feign.AuthzFeignService;
import com.jiangyg.mall.core.support.restful.Result;
import com.jiangyg.mall.core.utils.Logger;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 类描述：
 *
 * @author jiangyg
 * @date 2022-09-01
 */
@Slf4j
@Component
public class AuthzFeignServiceFallbackFactory implements FallbackFactory<AuthzFeignService> {


    @Override
    public AuthzFeignService create(Throwable ex) {
        return (path, attachParams) -> {
            Logger.error(log, () -> String.format("校验是否有路径[%s]的访问权限", path), ex);
            return Result.error();
        };
    }

}
